package com.cx.webpay.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @description:密码工具类
 **/
public class PwdUtil {
    /**
     * 获取加密后的密码
     * @param pwd
     * @return
     */
    public static String getPwdEncode(String pwd){
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(pwd);
    }

    /**
     * 判断密码是否一致
     * @param newPwd 新密码（未加密）
     * @param oldPwdEncode 旧密码（已加密）
     * @return
     */
    public static boolean matches(String newPwd,String oldPwdEncode){
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(newPwd,oldPwdEncode);
    }
    /*public static void main(String[] args){
      $2a$10$Nh8d57VWPlcx9MQ1k4lPF.bp/caIyL3Sh62qmhWOWPgE2EOy1qG9a
        $2a$10$WBsspcf.MrxoOuE2B/Zh4.VWUqIjK31EbP7s6ZgCc8hKL/WAMhL8S
        $2a$10$lGyNjUzyy0ymRjbiUSxukuSuE/VfoPKwks2oUHLoqEKKaZ3uF50te
        $2a$10$bhfTzKlVChLfRlV9wi0vxeTENDwhGb/X5Z9UeSHCslWv6gAfRRa5i
        $2a$10$S9HZ4PdqYi7phalVRoJVe.Id74DieER0rR/zINS1zWIFCRlJ.SNIG
        $2a$10$.GjFHGNdBQFzOh6ECKSmZe2E6b1rHD7NGL5bDg6zVl1.AGEFrBIjG
        $2a$10$Um/PZJXmbEDEpZlEsqZVteq821baC5Zepf90tBEjNRPRwshGP/pFa
        $2a$10$ki.X/8sDLZ.3Qcmi2OHvtedhr.Nb1gVVjKqcv73OyZhehyc2laJ0.
        $2a$10$1STaGO0J/YYk4MRJXWQjj.z.kT5r29M9hG9nrqX65eUUvDDra5VA2
        
        boolean b = matches("123456","$2a$10$Nh8d57VWPlcx9MQ1k4lPF.bp/caIyL3Sh62qmhWOWPgE2EOy1qG9a");
        System.out.println(b);
    }*/
}
